
// Readonly properties

interface Point {
  readonly x: number;
  readonly y: number;
}

let p1: Point = { x: 10, y: 20 };
// Cannot assign to 'x' because it is a read-only property. 只有第一次可以复制，之后不能再修改
p1.x = 5; // error!

let a: number[]
let ro: ReadonlyArray<number> = [1, 2, 3, 4];
// Index signature in type 'readonly number[]' only permits reading
ro[0] = 12; // error!
ro.push(5); // error!
ro.length = 100; // error!
// a = ro; // error!
a = ro as number[]